#pragma once

#include "BaseObject.hpp"
#include "Camera.h"
#include "Light.h"
#include "Sword.h"

// The player has a health counter and a gold counter. His health is reset each time he dies,
// or the level is reset. The level can be reset through pressing the generate button, or
// finding the final spinning cube.
//
// The camera and the light follow him, he holds onto an instance of each and modifies them as
// he moves, sending the information out to graphics when its time to render.
//
// He also has the ability to send his current health and gold count to the menu class.
//
// Player also has the ability to collide with walls, Pickup Items, and enemies.
class Character : public BaseObject
{
protected:
	float			m_fHealth;
	float			m_fGold;
#ifdef IMPLEMENT_SWORD
	Sword			*m_MyWeapon;
	eDirections		m_dirAttackDir;
#endif

public:

	float			m_LightRange;
	CameraObject	CameraMan;

	Character();
	Character(Character const &);
	Character(Character const &,D3DXVECTOR3 P);
	Character(D3DXVECTOR3 Pos);
	Character(float x,float y,float z);
	Character(float x,float y,float z,float GOLD);
	~Character(){}
	//Set, inits and resets
	virtual void Init();
	void Reset(){m_fHealth = 100;SetPosition(D3DXVECTOR3(15.0f,15.0f,0.0f));}
	void SetPosition(D3DXVECTOR3 P){
		m_vPosition = P;
		CameraMan.EyePos = GetCameraPosition();
		CameraMan.LookAt = GetPosition();
	}

	//Talking to other objects
	float GetHealth(){return m_fHealth;}
	float GetExp(){return m_fGold;}
	void SendStats(int To);

#ifdef IMPLEMENT_SWORD
	Sword* AccessWeapon(){return m_MyWeapon;}
	D3DXVECTOR3 WeaponPos(eDirections Dir);
#endif

	//Listening
	virtual void TranslateMessages();
	
	//Watching the world
	virtual bool Collided(DrawList* drawables,D3DXVECTOR3 NewPos);
	D3DXVECTOR3 GetPosition(){return m_vPosition;}
	D3DXVECTOR3 GetCameraPosition(){return D3DXVECTOR3(m_vPosition.x ,m_vPosition.y - 20,m_vPosition.z + 60);}
	
	//Talking to the commander
	void Draw();
	void* Update(void* Data);
	void UpdateBox();
	
	//Questioning life
	bool IfDied(){if(m_fHealth <= 0)return true;return false;}
};